package com.broadengate.action;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.broadengate.form.CancelAccountForm;
import com.broadengate.model.Card;
import com.broadengate.model.Deposit;
import com.broadengate.model.Transfer;
import com.broadengate.model.Withdraw;
import com.broadengate.service.AdminService;
import com.broadengate.service.CardService;
import com.broadengate.service.DepositService;
import com.broadengate.service.TransferService;
import com.broadengate.service.WithdrawService;

public class CancelAccountAction extends DispatchAction {

	private AdminService adminService;
	private CardService cardService;
	/*private DepositService depositService;
	private WithdrawService withdrawService;
	private TransferService transferService;*/
	
	public ActionForward cancel(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		
		CancelAccountForm cancelAccountForm=(CancelAccountForm)form;
		HttpSession session=request.getSession();
		if(cardService.findCardByCardNO(cancelAccountForm.getAccountCancel())==null){
	
			return mapping.findForward("fail");
		}
		Card card = cardService.findCardByCardNO(cancelAccountForm.getAccountCancel());
		String cardID=card.getId().toString(); 
		
			
		
		try {
			adminService.cancelAccount(cardID);
			session.setAttribute("again","suc");
			return mapping.findForward("success");
		} catch (Exception e) {
			e.printStackTrace();
			return mapping.findForward("fail");
		}

	}

	public AdminService getAdminService() {
		return adminService;
	}

	public void setAdminService(AdminService adminService) {
		this.adminService = adminService;
	}

	public CardService getCardService() {
		return cardService;
	}

	public void setCardService(CardService cardService) {
		this.cardService = cardService;
	}

	/*public DepositService getDepositService() {
		return depositService;
	}

	public void setDepositService(DepositService depositService) {
		this.depositService = depositService;
	}

	public WithdrawService getWithdrawService() {
		return withdrawService;
	}

	public void setWithdrawService(WithdrawService withdrawService) {
		this.withdrawService = withdrawService;
	}

	public TransferService getTransferService() {
		return transferService;
	}

	public void setTransferService(TransferService transferService) {
		this.transferService = transferService;
	}
	*/
	
}
